var reg = new RegExp("\\\\x", "g"),
  str_pad = require('./str_pad'),
  crypto = require('crypto'),

  md5 = function (str) {
    var md5sum = crypto.createHash('md5');
    md5sum.update(str);
    str = md5sum.digest('hex');
    return str;
  },

  hex2char = function ($num){
    $s = '';
    for(var $i=0;$i<$num.length;$i+=2){
      $s += String.fromCharCode( parseInt( $num.substr($i, 2), 16 ));
    }
    return $s;
  };

module.exports = function getPassword($qq, $password, $verifycode){

  $uin = str_pad(parseInt($qq).toString(16), 16, "0", 'STR_PAD_LEFT');
	$p = hex2char(md5($password));
	$u = md5(  $p + hex2char( $uin.replace(reg, "") ) ).toUpperCase();
	$v = md5(  $u + $verifycode.toUpperCase() ).toUpperCase();

	return $v;
};